/*
 * @Author: lvye
 * @Description:
 * @Date: 2023-08-25 17:52:45
 * @LastEditTime: 2023-08-25 17:57:16
 * @FilePath: \vue3-ts\src\utils\date-format.ts
 */
import dayjs from "dayjs"
import utc from "dayjs/plugin/utc"
dayjs.extend(utc)
const DATE_TIME_FORMAT = "YYYY-MM-DD HH:mm:ss"
// 用于格式化时间
export const dateFormat = (
  date: string | number | Date,
  format = DATE_TIME_FORMAT
) => {
  return dayjs(date).format(format)
}
// 用于格式化UTC时间
export const formatUtcString = (
  utcString: string,
  format = DATE_TIME_FORMAT
) => {
  return dayjs.utc(utcString).utcOffset(8).format(format)
}
